$(document).ready(function(){
    $('.bt-login').on('click', '', function(){
        var mobile = $('#mobile-login').val();
        if (mobile == ''){
            alert('手机号码不能为空');
            return false;
        }

        var password = $('#password-login').val();
        if (password == ''){
            alert('密码不能为空');
            return false;
        }
        $.post('/user/login',{mobile:mobile, password:password, _csrf:$('#YII_CSRF_TOKEN2').val()},function(data){
            alert(data.msg);
            if(data.code == 10000) {
                location.href = '/member/index';
            }
            return false;
        },'json');
        return false;
    });

    $('.bt-register').on('click', '',function(){
        var mobile = $('#mobile').val();
        if (mobile == ''){
            alert('手机号码不能为空');
            return false;
        }
        if (!mobile.match(/^1[3-9]{1}\d{8}$/)){
            alert('手机号码格式不正确');
            return false;
        }
        var password = $('#password').val();
        if (password == ''){
            alert('密码不能为空');
            return false;
        }
        var repassword = $('#repassword').val();
        if (repassword == ''){
            alert('请再次输入密码');
            return false;
        }
        if($('.drag_text').text() != '验证通过'){
            alert('非法的操作');
            return false;
        }

        $.post('/user/register',{mobile:mobile, password:password, repassword:repassword,_csrf:$('#YII_CSRF_TOKEN').val()},function(data){
            alert(data.msg);
            if(data.code != 10000) {
                return false;
            }
        },'json');
        return false;
    });
    $('#drag').drag();
});
